package cn.xk.ymcc.service.impl;

import cn.xk.ymcc.domain.CourseChapter;
import cn.xk.ymcc.mapper.CourseChapterMapper;
import cn.xk.ymcc.service.ICourseChapterService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 课程章节 ， 一个课程，多个章节，一个章节，多个视频 服务实现类
 * </p>
 *
 * @author 64009120@qq.com
 * @since 2023-03-11
 */
@Service
public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, CourseChapter> implements ICourseChapterService {
    @Override
    public boolean insert(CourseChapter entity) {
        Wrapper<CourseChapter> wrapper = new EntityWrapper<>();
        wrapper.eq("course_id", entity.getCourseId());
        int i = super.selectCount(wrapper)+1;
        entity.setNumber(i);
        return super.insert(entity);
    }
}
